package cn.iocoder.yudao.module.engine.service.core.pipeline;

import cn.iocoder.yudao.module.engine.service.core.filter.common.HeadFilter;
import cn.iocoder.yudao.module.engine.service.core.filter.common.TailFilter;

public class FilterManager {
    // 单例
    private static final FilterManager INSTANCE = new FilterManager();

    public static FilterManager getInstance() {
        return INSTANCE;
    }

    private final FilterPipeline pipeline;

    private FilterManager() {
        this.pipeline = new FilterPipeline();
    }

    public FilterPipeline getPipeline() {
        return pipeline;
    }

    public void initPipeline(FilterAdapter tailFilter) {
        pipeline.init(
                new FilterContext(pipeline, new HeadFilter(), "head"),
                new FilterContext(pipeline, tailFilter != null ? tailFilter : new TailFilter(), "tail")
        );
    }

}
